#include "application.h"
#include <iostream>

#include <GLUT/glut.h>
using namespace std;

Application* Application::m_instance = NULL;

void
Application::Init(int argc, char **argv)
{
    /** Initialize GLUT **/
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    m_rotateAllowed = false;
    m_cameraDistance = 1.0f;
    m_cameraAngleX = 0.0f;
    m_cameraAngleY = 0.0f;

    
    // Controls strings
    m_appStrings[C_GEOMETRY] = "Geometry";
    m_appStrings[C_GEOMETRYTYPE] = "Solid";
   
    // Control default values
    m_geometry = G_TEAPOT;
    m_geometryType = 1;

    // Specify geometry list box strings
    SPECIFYAPPSTRING(G_TORUS);
    SPECIFYAPPSTRING(G_SPHERE);
    SPECIFYAPPSTRING(G_CUBE);
    SPECIFYAPPSTRING(G_CONE);
    SPECIFYAPPSTRING(G_DODECAHEDRON);
    SPECIFYAPPSTRING(G_TETRAHEDRON);
    SPECIFYAPPSTRING(G_ISOCAHEDRON);
    SPECIFYAPPSTRING(G_OCTAHEDRON);
    SPECIFYAPPSTRING(G_TEAPOT);

}

Application*
Application::getInstance()
{
    if (!m_instance)
    {
        m_instance = new Application;
    }

    return m_instance;
}

Application::~Application()
{
    GLUI_Master.close_all();
}

void
Application::update(int controlID)
{
    switch (controlID)
    {
        case C_GEOMETRY:
            break;
        default:
            break;
    }
    
    // Redraw the render window
    glutPostRedisplay();
}

const char*
Application::getString(int key)
{
    return m_appStrings[key].c_str();
}

